<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                 label-width="68px">
            <el-form-item label="名称" prop="name">
                <el-input v-model="queryParams.name" placeholder="请输入名称" clearable
                          @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="排站规则" prop="allotPlaceRule">
                <el-select v-model="queryParams.allotPlaceRule" placeholder="请选择排站规则" clearable>
                    <el-option v-for="dict in dict.type.score_ex_model_allot_place_rule_dict" :key="dict.value"
                               :value="dict.value" :label="dict.label"/>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="ex_modelList">
            <el-table-column label="名称" align="center" prop="name"/>
            <el-table-column label="最大学生数" align="center" prop="maxStudent"/>
            <el-table-column label="现场考官权重(%)" align="center" prop="sceneExaminerWi"/>
            <el-table-column label="中控考官权重(%)" align="center" prop="centerExaminerWi"/>
            <el-table-column label="远程考官权重(%)" align="center" prop="sshExaminerWi"/>
            <el-table-column label="考试间隔时间(分)" align="center" prop="examIntervalTime"/>
            <el-table-column label="考场数量" align="center" prop="scoreExModelPlaceCount"/>
            <el-table-column label="排站规则" align="center" prop="allotPlaceRule">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.score_ex_model_allot_place_rule_dict"
                              :value="scope.row.allotPlaceRule"/>
                </template>
            </el-table-column>
            <el-table-column label="必过技能" align="center" prop="mustSkillList" :formatter="skillFormat"/>
            <el-table-column label="选择" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button type="success" icon="el-icon-thumb" @click="checkModel(scope.row)" plain circle/>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                    @pagination="getList"/>
    </div>
</template>

<script>
import {listEx_model} from "@/api/score/ex_model";

export default {
    name: "Ex_model",
    dicts: ['score_ex_model_must_skill_dict', 'score_ex_model_allot_place_rule_dict'],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 考试模版表表格数据
            ex_modelList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                name: null,
                allotPlaceRule: null,
            },
        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询考试模版表列表 */
        getList() {
            this.loading = true;
            listEx_model(this.queryParams).then(response => {
                this.ex_modelList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 选择模版 */
        checkModel(row) {
            this.$emit("handleCheckModel",row.id);
        },
        //必过技能格式化
        skillFormat(row, column, cellValue) {
            let str = '';
            for (let i = 0; i < cellValue.length; i++) {
                str += cellValue[i];
                if (i != cellValue.length - 1) {
                    str += '、';
                }
            }
            return str;
        },
    }
};
</script>

